'''
Created on Oct 5, 2010

@author: Bernardo Kyotoku
'''
import numpy as np


#    A[0] = [X1,X2,...,Xn]
#    or
#    A[0] = [X,Y]

#    Same behavior
#    A*B,A+B,A-B,A/B
#

#    Incompatible
#    extracting angle function
#    extracting norm function
#    extracting inner product function

#    A[0] = [X1,X2,...,Xn]
#    inner product np.sum(A*B,0)

#    Advantages of A[0] = [X1,X2,...,Xn]

#    Drawbacks of A[0] = [X1,X2,...,Xn]

#    A[0] = [X,Y]
#    inner product np.sum(A*B,1)

#    Advantages of A[0] = [X,Y]

#    Drawbacks of A[0] = [X,Y]


#    Angle vs Directional vector
#    Pro Angle
#    angle easily summed and subtracted
#    Pro Directional vector
#    easy to calculate a point in from certain direction

#class Vector(object):
#    '''
#    X,Y (2 doubles)
#    
#    array of doubles or make array or points externally?
#    
#    array of doubles
#    all operations needs to be arrayed
#    
#    
#    
#    ''' 
#    
#    def norm(self):
#        '''
#    ok to be arrayed
#        '''
#        pass
#    
#    def add(self):
#        '''
#        ok to be arrayed
#        '''
#        pass
#    
#    def subtract(self):
#        '''
#        ok to be arrayed
#        '''
#        pass
#    
#    def innerProduct(self):
#        '''
#        Behavior
#        if target is a single vector
#            operate inner product with all array of vectors
#        else if target is an array of vector
#            target number of vector needs to be equal to the number of source
#            vectors.
#            make inner product one by one
#        '''
#        pass
#    
#    def externalProduct(self):
#        '''
#        Behavior
#        if target is a single vector
#            operate inner product with all array of vectors
#        else if target is an array of vector
#            target number of vector needs to be equal to the number of source
#            vectors.
#            make inner product one by one
#        '''
#        pass
        
class Normal(object):
    def __init__(self):
        self.value = 0
        self.updated = False        
    def __get__(self,instance,owner):
        if not self.updated:
            self.value = np.vstack([np.cos(instance.angle),np.sin(instance.angle)])
            self.updated = True
        return self.value
    def __set__(self,instance,value):
        self.value = value
        self.updated = True
        instance.angle.updated = False
        
class Angle(object):
    def __init__(self):
        self.value = 0
        self.updated = False
    def __get__(self,instance,owner):
        if not self.updated:
            self.value = np.arctan2(instance.normal)
            self.updated = True
        return self.value
    def __set__(self,instance,value):
        self.value = np.arctan2(value)
        self.updated = True
        instance.normal.updated = False
        
class Curves(object):
    '''    
    points - an array of points in the curve
    convention 
    x = points[0]
    y = points[1]        
    
    angles - an array of angles for the normal of the curve
             in respect to the X axis.
             
    a.points
    a.angles
    a.normals
    
    problems on how it is stored internally.
        if angles stored 
            needs computation to get normals
        if normals stored
            needs computation to get normals and uses more memory
             
    '''        
    def __init__(self):
        '''
        Constructor
        '''
        self.point = 0
        self.width = 0
        self.angle = Angle()
        self.normal = Normal()
    
        
#class Line(object):
#    '''
#    Attributes
#    Point, angle (3 doubles)
#    ''' 
#
#    pass           
#        
#class LineSegment(object):
#    '''
#    Attributes
#    Point A, Point B (4 doubles)
#    Point, normal angle, length (4 doubles)
#    Line, length (4 doubles)    
#    '''
#    def length(self):
#        pass
#    
#    def endPoints(self):
#        pass
#    
#    def middlePoint(self):
#        pass
#    
#    def angle(self):
#        pass
#    
#    def normal(self):
#        pass
#    
#    
#
# 